(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.lookup.documentController', documentController);
	documentController.$inject = [ '$scope', '$q', '$uibModalInstance', 'Constants', 'dialogsModule', 'gridService', 'modalService', 'layoutConfig',
	                              'validatorConfig', 'authService', 'ajaxServiceFactory'];
	function documentController($scope, $q, $uibModalInstance, Constants, dialogsModule, gridService, modalService, layoutConfig, validatorConfig, authService, ajaxServiceFactory) {
		var ctrl = this, log = $scope.loggerFactory.getLogger("documentLookup");
		ctrl.dialogsModule = dialogsModule;
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		var documentInfo = $scope.$stateParams.params;
		
		ctrl.close = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback['close'] || dialogsModule.btnCallback['close']() !== false) {
				$uibModalInstance.dismiss();
			}
		};
		
		ctrl.init = function() {
			var params = {
					docId : documentInfo.id || documentInfo.docId
				};
			return authService.viewDetail(params).then(function(response) {
				ctrl.document = response.data || document;
			}, angular.noop);
		
		};
		
	}
})(angular);
